package utils;


public class ByteUtils {

	
	/**
	 * 
	 * @param para, only byte or byte array accepted
	 * @return
	 */
	public static byte[] buildByteArray(Object... para){
		ByteStack bs = new ByteStack();
		for(Object obj : para){
			if(obj.getClass() == byte[].class){
				bs.write((byte[])obj);
			}else if(obj.getClass().getSuperclass() == Number.class){
				bs.write(((Number)obj).byteValue());
			}else if(obj.getClass() == Character.class){
				bs.write((byte)((Character)obj).charValue());
			}else{
				System.err.println("Cast away: "+ obj.getClass()+", "+obj.toString());
			}
		}
		
		return bs.getByteArray();
	}
	
	
	public static boolean equals(byte[] tom, byte[] jerry){
		boolean b = true;
		
		if(tom.length!=jerry.length){
			b = false;
		}else{
			for(int i=0;i<tom.length;i++){
				if(tom[i]!=jerry[i]){
					b = false;
					break;
				}
			}
		}
		return b;
	}
	
	
	public static void main(String[] args) {
		System.out.println(new Character('-').charValue());
		System.out.println((int)'-');
	}
	
}
